package com.hrt.test.db;

import java.text.SimpleDateFormat;
import java.util.Date;

import org.junit.Test;

import com.btcode.common.ExecuteTimeUtil;
import com.btcode.common.MyLog;
import com.btcode.common.PropertiesUnit;
import com.btcode.db.executer.IDataExecuter;
import com.hrt.db.DBManager;

public class queryDB {

    @Test
    public void testTimeOut() throws InterruptedException {

        System.out.println("开始查询");

        ExecuteTimeUtil time = new ExecuteTimeUtil();

        SimpleDateFormat sf = new SimpleDateFormat("HH:mm:ss");

        PropertiesUnit.setPropertiesPath("E:/workspace/DataSenderV2/DataSenderV2/resource/");
        MyLog.getInstance().setRootPath("d:/DataSender");
        IDataExecuter dataExecuter = DBManager.getDataExecuter();

        System.out.println("获取数据库对象所花时间：" + time.getLastDiff());

        try {
            dataExecuter.update("PRAGMA busy_timeout = 0;", null);
            dataExecuter.update(
                    "update BC_MONITOR_PARAM_DICT set UNIT = '" + sf.format(new Date()) + "' where id='356722'", null);
        } catch (Exception e) {
            System.out.println("执行语句所花时间：" + time.getLastDiff());
            throw e;
        }

        System.out.println("执行语句所花时间：" + time.getLastDiff());
    }

}
